package com.sky.web.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderSubmitVO;
import com.sky.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @GetMapping("conditionSearch")
    public Result conditionSearch(OrdersPageQueryDTO dto){
       PageResult pageResult = orderService.conditionSearch(dto);

        return Result.success(pageResult);
    }

    @GetMapping("statistics")
    public Result statistics(){
       OrderStatisticsVO vo = orderService.statistics();

        return Result.success(vo);
    }

    @GetMapping("details/{id}")
    public Result details(@PathVariable Long id){
       OrderVO vo = orderService.details(id);

        return Result.success(vo);
    }

    @PutMapping("confirm")
    public Result confirm(@RequestBody OrdersConfirmDTO dto){
        orderService.confirm(dto);
        return Result.success();
    }

    @PutMapping("rejection")
    public  Result rejection(@RequestBody OrdersRejectionDTO dto){
        orderService.rejection(dto);
        return Result.success();
    }

    @PutMapping("cancel")
    public Result cancelOrder(@RequestBody OrdersCancelDTO dto){
        orderService.cancelOrder(dto);

        return Result.success();
    }

    @PutMapping("delivery/{id}")
    public Result delivery(@PathVariable Long id){
        orderService.delivery(id);
        return Result.success();
    }

    @PutMapping("complete/{id}")
    public Result  complete(@PathVariable Long id){
        orderService.complete(id);
        return Result.success();
    }
}
